package com.alisls.demo.springcloud.service.user.config;

import com.alisls.demo.springcloud.common.core.util.IdWorker;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.web.client.RestTemplate;

/**
 * 用户服务配置类
 *
 * @author Ke Wang
 */
@Configuration
@RefreshScope
public class ServiceUserConfig {

    /**
     * BCryptPasswordEncoder 加密算法
     *
     * @return PasswordEncoder
     */
    @Bean
    public PasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }

	@Bean
	public IdWorker idWorker() {
		return new IdWorker();
	}

	@Bean
	public ServiceUserProp serviceUserProp() {
	    return new ServiceUserProp();
    }

	@Bean
	@LoadBalanced
	public RestTemplate restTemplate() {
		return new RestTemplate();
	}
	
}
